
using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
using GruntXProductions;
using Viper;
using Viper.Opcodes;

namespace Diamond
{
	public partial class CodeGen 
	{
		private static uint ifIndex = 0;
		public void ParseIf(IfStatement ifstat)
		{
			ParseBooleanExpression(ifstat.Comparison);
			string label = "if_" + ifIndex.ToString();
			string label2 = "else_" + ifIndex.ToString();
			ifIndex++;
			Assembler.Emit(new bz(label));
			CompileBlock(ifstat.Body);
			Assembler.Emit(new bra(label2));
			Assembler.CreateLabel(label);
			CompileBlock(ifstat.Else);
			Assembler.CreateLabel(label2);
			
		}
	}
	
}